package com.liujun.spring4.demo.aop.aop.jdkproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * 动态代理类的实现
 * @author liujun
 * @version 0.0.1
 * @date 2018/09/19
 */
public class PerformanceHandler implements InvocationHandler {

    private Object targer;

    public PerformanceHandler(Object targer) {
        this.targer = targer;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        PerformanceMonitor.begin(targer.getClass().getName() + "."+method.getName());

        Object result = method.invoke(targer,args);

        PerformanceMonitor.end();

        return result;
    }
}
